package nieAS.ui {
	import flash.display.DisplayObjectContainer;
	import flash.events.ContextMenuEvent;
	import flash.net.navigateToURL;
	import flash.net.URLRequest;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;
	
	public class Mouse {
		
		public static function setMouseRightClick(_root:DisplayObjectContainer, gameName:String = null, gameIndex:String = null):void {
			var rightContextMenu:ContextMenu = new ContextMenu();
			rightContextMenu.hideBuiltInItems();
			
			if (gameName != null) {
				var gameButton:ContextMenuItem = new ContextMenuItem(gameName);
				if (gameIndex != null) {
					gameButton.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function():void {
							navigateToURL(new URLRequest(gameIndex));
						});
				}
				rightContextMenu.customItems.push(gameButton);
			}
			
			_root.contextMenu = rightContextMenu;
		}
	}
}